<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>

<%@page import="java.util.*, model.*"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html:html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<title>Country of Residence</title>
		<style>
			table {border: 1px solid black;}
		</style>
	</head>
		<body>
			<%
				Applicant applicant = (Applicant)session.getAttribute("applicant");
				Vector locationsVector = (Vector)session.getAttribute("locationsVector");
				Degree degree = (Degree)session.getAttribute("degree");
				Vector degreesVector = (Vector)session.getAttribute("degreeVector");
				Vector<String> statesVector = (Vector) session.getAttribute("statesVector");
				String degreesString = Database.printDegrees(degreesVector);
			%>
			
			<%="Name: " + applicant.getName() %><br />
			<%="Country of Citizenship: " + applicant.getCitizenship() %> <br />
			<%="Country of Residence: " + applicant.getCountry_of_residence() %><br/>
			<%if(applicant.isDomestic()){ %>
			<%="Address: " + applicant.getAddressDomestic() %><br/>
			<%}else{%>
			<%="Address: " + applicant.getAddressForeign() %><br/>
			<%} %>
			<%= applicant.getDomestic() %>
			
			<!-- Print Degrees -->
			
			<hr /><br /> Choose a location you have a Degree from: <br /><br />
			<logic:notPresent parameter="state">
			<table>
			<tr>
				<td>
					<a href="/StrutsCSE135/pages/students/degrees_university.jsp?location=United%20States">United States</a> <br /><br />
					<%  int count = locationsVector.size()-51;
						int i = 51;
		 				for(; i<count; i++){
		 					out.println("<a href=\"/StrutsCSE135/pages/students/degrees_university.jsp?location=" + locationsVector.get(i) + "\">" + locationsVector.get(i) + "</a>");
		 		      		out.println("<br />");
		 				} 
					%>
				</td>
				<td>
					<% 
		 				for( i=count/3 + 1; i < (count/3)*2 + 1; i++){ 
		 					out.println("<a href=\"/StrutsCSE135/pages/students/degrees_university.jsp?location=" + locationsVector.get(i) + "\">" + locationsVector.get(i) + "</a>");
		 		      		out.println("<br />");
		 				} 
					%>
				</td>
				<td>
					<% 
		 				for( i = (count/3)*2 + 1; i<count; i++){ 
		 					out.println("<a href=\"/StrutsCSE135/pages/students/degrees_university.jsp?location=" + locationsVector.get(i) + "\">" + locationsVector.get(i) + "</a>");
		 		      		out.println("<br />");
		 				} 
					%>
				</td>
			</tr>
		</table> 
		</logic:notPresent>
		<logic:present parameter="state">
			<%
			degree.setCountry("United States");
			int count = statesVector.size();
			int i = 0;
				for(i=0; i<count; i++){
					out.println("<a href=\"/StrutsCSE135/pages/students/degrees_university.jsp?state=" + statesVector.get(i) + "\">" + statesVector.get(i) + "</a>");
		      		out.println("<br />");
				}
				%>
		</logic:present>

</body>
</html:html>